USE [SimpoBudget]
GO

/****** Object:  Table [dbo].[BudgetItem]    Script Date: 02/15/2014 14:23:54 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BudgetItem](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[MinimumAmount] [decimal](18, 2) NULL,
	[DueDate] [datetime] NULL,
	[PastDueAmount] [decimal](18, 2) NULL,
	[PastDueDate] [datetime] NULL,
	[TotalAmount] [decimal](18, 2) NULL,
	[PlannedPayDate] [datetime] NULL,
	[PlannedPayAmount] [decimal](18, 2) NULL,
	[StatusID] [int] NOT NULL,
	[AccountID] [int] NULL,
	[BillID] [int] NULL,
	[PaycheckID] [int] NULL,
 CONSTRAINT [PK_BudgetItem] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[BudgetItem]  WITH CHECK ADD  CONSTRAINT [FK_BudgetItem_Account] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Account] ([ID])
GO

ALTER TABLE [dbo].[BudgetItem] CHECK CONSTRAINT [FK_BudgetItem_Account]
GO

ALTER TABLE [dbo].[BudgetItem]  WITH CHECK ADD  CONSTRAINT [FK_BudgetItem_Bill] FOREIGN KEY([BillID])
REFERENCES [dbo].[Bill] ([ID])
GO

ALTER TABLE [dbo].[BudgetItem] CHECK CONSTRAINT [FK_BudgetItem_Bill]
GO

ALTER TABLE [dbo].[BudgetItem]  WITH CHECK ADD  CONSTRAINT [FK_BudgetItem_Paycheck] FOREIGN KEY([PaycheckID])
REFERENCES [dbo].[Paycheck] ([ID])
GO

ALTER TABLE [dbo].[BudgetItem] CHECK CONSTRAINT [FK_BudgetItem_Paycheck]
GO

ALTER TABLE [dbo].[BudgetItem]  WITH CHECK ADD  CONSTRAINT [FK_BudgetItem_Status] FOREIGN KEY([StatusID])
REFERENCES [dbo].[Status] ([ID])
GO

ALTER TABLE [dbo].[BudgetItem] CHECK CONSTRAINT [FK_BudgetItem_Status]
GO

